using System.Web.UI;
using System.Web.UI.WebControls;
using ud_Poll.Business;
using System.Drawing;
using mojoPortal.Web.Framework;

namespace ud_Poll.Helpers
{
    public static class PollUIHelper
    {
        public static void AddResultBarToControl(PollOption option, string hexColor, Control ctrl)
        {
            Unit imgWidth = Unit.Percentage(option.VotePercentage == null || option.VotePercentage == 0 ?
                1 : option.VotePercentage.Value);
            Color color = UIHelper.HexStringToColor(hexColor);
            Label lbl = new Label {BackColor = color, Height = Unit.Pixel(10), Width = imgWidth};
            ctrl.Controls.Add(lbl);
        }
    }
}
